﻿/*
 * Autore: Artur Tolstenco
 */

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace RecipesManager.MainControls.RecipeSubControls
{
    /// <summary>
    /// Interaction logic for StepSubControl.xaml
    /// </summary>
    public partial class NoteSubControl : UserControl
    {
        string _currentRecipeName;

        public NoteSubControl()
        {        
            InitializeComponent();
        }

        public string CurrentRecipeName
        {
            get { return _currentRecipeName; }
            set
            {
                _currentRecipeName = value;
                MyInitialize();
            }
        }

        void MyInitialize()
        {
            tb_title.Text = Application.Current.FindResource("AddNoteToRecipeTitle") + " " + _currentRecipeName;
            bt_salva.Content = new Image { Source = new BitmapImage(new Uri("../../Icons/document-add.png", UriKind.Relative)) };
            bt_salva.ToolTip = Application.Current.FindResource("AddNoteToRecipeTooltip");
            tb_note_description.Text = "";
            tb_note_description.Focus();
            bt_salva.IsEnabled = IsModified();

        }

        public bool IsModified()
        {
            return !tb_note_description.Text.Equals("");
        }

        private void Tb_Note_Description_TextChanged(object sender, TextChangedEventArgs e)
        {
            bt_salva.IsEnabled = IsModified();
        }
    }
}
